class Solution {
public:
    vector<string> summaryRanges(vector<int>& nums) {
        vector<string> ret;
        int i = 0, n = nums.size();
        while (i < n) {
            int low = i++;
            while (i < n && nums[i] == nums[i - 1] + 1) i++;
            int hight = i - 1;
            string temp = to_string(nums[low]);
            if (low < hight) {
                temp.append("->");
                temp.append(to_string(nums[hight]));
            }
            ret.push_back(temp);
        }
        return ret;
    }
};
